package com.chinasofti.filestream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Demo02 {
    //创建字节输出流
    public static void main(String[] args) throws IOException {
        //注意：如果文件不存在会帮我们自动创建
        FileOutputStream fileOutputStream = new FileOutputStream("java0418\\fox.txt");
        //将字节写入文件输出流
//        fileOutputStream.write(100);
//        fileOutputStream.write(101);
//        fileOutputStream.write(102);
//        fileOutputStream.write(103);
//        byte [] bytes = {97,98,99,100};
        byte [] bytes ="hanmeimie".getBytes();
//                fileOutputStream.write(bytes,1,3);
                fileOutputStream.write(bytes,0,bytes.length);

        //最后释放资源
        fileOutputStream.close();
    }
}
